//package Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.Extensions.RelationShip
//
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.Extensions.*
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.IDBTable
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.IQueriableCollection
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.QueryBuilderExtensions.SelectQueryExpression.equals
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.QueryBuilderExtensions.SelectQueryExpression.single
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.IDataContext
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.MySql.MySqlDataContext
//import java.sql.Connection
//import java.sql.DriverManager
//
//interface IPerson {
//    val id: Int
//    var name: String
//    var password: String
//    var companyId: Int
//    var company: ICompany
//}
//
//interface ICompany {
//    val id: Int
//    var name: String
//    var webSite: String
//    val users: MutableCollection<IPerson>
//}
//
//object Persons : DBTable("User") {
//    override var Comment = "ئەزالار"
//    val ID = idColumn("ID") comment "ID"
//    val Name = stringColumn("Name") size 100 notNull true comment "ئىسمى"
//    val Pwd = stringColumn("Pwd") notNull true size 32 comment "پارولى"
//    val CompanyID = intColumn("CompanyID") unsigned true notNull true reference Companies.ID comment "شىركەت ID"
//
//    init {
//        index(Name, Pwd) unique true
//    }
//}
//
//object Companies : DBTable("Company") {
//    override var Comment: String = "شىركەت"
//    val ID = idColumn("ID") comment "ID"
//    val Name = stringColumn("Name") notNull true comment "ئىسمى"
//    val WebSite = stringColumn("WebSite") notNull true comment "تور بەت ئادېرسى"
//
//    init {
//        index(Name) unique true
//    }
//}
//
//class Person(DataContext: IDataContext) : DBEntity(DataContext, Persons), IPerson {
//    override val id by Persons.ID
//    override var name by Persons.Name
//    override var password by Persons.Pwd
//    override var companyId by Persons.CompanyID
//    override var company: ICompany by hasOne(Persons.CompanyID) { Company(it) }
//}
//
//class Company(DataContext: IDataContext) : DBEntity(DataContext, Companies), ICompany {
//    override val id by Companies.ID
//    override var name by Companies.Name
//    override var webSite by Companies.WebSite
//    override val users: IQueriableCollection<IPerson> by hasMany(Persons.CompanyID) { Person(it) }
//}
//
//class dataContext(connection: Connection) : MySqlDataContext(connection) {
//    override val tables: Array<IDBTable> = arrayOf(Companies, Persons)
//    val users = dbCollection(Persons) { Person(it) }
//    val companies = dbCollection(Companies) { Company(it) }
//}
//
//fun main(args: Array<String>) {
//    val myDb = dataContext(DriverManager.getConnection("jdbc:mysql://localhost:3308/Hello", "root", "WeAreDevelopers"))
//
////    myDb.createNewTables(Persons, Companies)
//
//    val company1 = myDb.companies.single { Companies.Name equals "Sarkar Software Technologys" }
//
//
//    val person1 = Person(myDb).apply {
//        name = "مۇتەللىپجان"
//        password = "MUU653125"
//        company = company1
//    }
//
//    myDb.users.add(person1)
//    println(myDb.saveChanges())
//}
//package Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.Extensions.RelationShip
//
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.Extensions.*
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.IDBTable
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.IQueriableCollection
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.QueryBuilderExtensions.SelectQueryExpression.equals
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.Core.QueryBuilderExtensions.SelectQueryExpression.single
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.IDataContext
//import Cn.Sarkar.EntityDream.CoreEngine.RDBMS.MySql.MySqlDataContext
//import java.sql.Connection
//import java.sql.DriverManager
//
//interface IPerson {
//    val id: Int
//    var name: String
//    var password: String
//    var companyId: Int
//    var company: ICompany
//}
//
//interface ICompany {
//    val id: Int
//    var name: String
//    var webSite: String
//    val users: MutableCollection<IPerson>
//}
//
//object Persons : DBTable("User") {
//    override var Comment = "ئەزالار"
//    val ID = idColumn("ID") comment "ID"
//    val Name = stringColumn("Name") size 100 notNull true comment "ئىسمى"
//    val Pwd = stringColumn("Pwd") notNull true size 32 comment "پارولى"
//    val CompanyID = intColumn("CompanyID") unsigned true notNull true reference Companies.ID comment "شىركەت ID"
//
//    init {
//        index(Name, Pwd) unique true
//    }
//}
//
//object Companies : DBTable("Company") {
//    override var Comment: String = "شىركەت"
//    val ID = idColumn("ID") comment "ID"
//    val Name = stringColumn("Name") notNull true comment "ئىسمى"
//    val WebSite = stringColumn("WebSite") notNull true comment "تور بەت ئادېرسى"
//
//    init {
//        index(Name) unique true
//    }
//}
//
//class Person(DataContext: IDataContext) : DBEntity(DataContext, Persons), IPerson {
//    override val id by Persons.ID
//    override var name by Persons.Name
//    override var password by Persons.Pwd
//    override var companyId by Persons.CompanyID
//    override var company: ICompany by hasOne(Persons.CompanyID) { Company(it) }
//}
//
//class Company(DataContext: IDataContext) : DBEntity(DataContext, Companies), ICompany {
//    override val id by Companies.ID
//    override var name by Companies.Name
//    override var webSite by Companies.WebSite
//    override val users: IQueriableCollection<IPerson> by hasMany(Persons.CompanyID) { Person(it) }
//}
//
//class dataContext(connection: Connection) : MySqlDataContext(connection) {
//    override val tables: Array<IDBTable> = arrayOf(Companies, Persons)
//    val users = dbCollection(Persons) { Person(it) }
//    val companies = dbCollection(Companies) { Company(it) }
//}
//
//fun main(args: Array<String>) {
//    val myDb = dataContext(DriverManager.getConnection("jdbc:mysql://localhost:3308/Hello", "root", "WeAreDevelopers"))
//
////    myDb.createNewTables(Persons, Companies)
//
//    val company1 = myDb.companies.single { Companies.Name equals "Sarkar Software Technologys" }
//
//
//    val person1 = Person(myDb).apply {
//        name = "مۇتەللىپجان"
//        password = "MUU653125"
//        company = company1
//    }
//
//    myDb.users.add(person1)
//    println(myDb.saveChanges())
//}
